//
//  USocialShareView.m
//  EasyFundraise
//
//  Created by Hangshao on 2016/11/7.
//  Copyright © 2016年 Toocms. All rights reserved.
//

#import "USocialShareView.h"

@interface USocialShareView()

@property (nonatomic, copy) BtnsClickBlock weibo;
@property (nonatomic, copy) BtnsClickBlock space;
@property (nonatomic, copy) BtnsClickBlock qq;
@property (nonatomic, copy) BtnsClickBlock weiChat;

@end

@implementation USocialShareView

+ (void)showWithWeiBo:(BtnsClickBlock)weibo
                space:(BtnsClickBlock)space
                   qq:(BtnsClickBlock)qq
              weiChat:(BtnsClickBlock)weiChat
{
    USocialShareView *view = [[USocialShareView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    view.weibo = weibo;
    view.space = space;
    view.qq = qq;
    view.weiChat = weiChat;
    
    //添加到窗口上
    [[UIApplication sharedApplication].keyWindow addSubview:view];
}

- (instancetype)initWithFrame:(CGRect)frame
{

    if (self = [super initWithFrame: frame]) {
        
        self =[[[NSBundle mainBundle] loadNibNamed:@"USocialShareView" owner:nil options:nil] firstObject];
        
        self.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.3];
        
        self.frame = frame;
    }
    
    return self;
}

- (IBAction)weiboBtn:(UIButton *)sender {
    
     [self removeFromSuperview];
    
    if (self.weibo) {
        self.weibo();
    }
    
}
- (IBAction)space:(UIButton *)sender {
    
     [self removeFromSuperview];
    
    if (self.space) {
        self.space();
    }
}
- (IBAction)qq:(UIButton *)sender {
    
     [self removeFromSuperview];
    
    if (self.qq) {
        self.qq();
    }
}
- (IBAction)wechat:(UIButton *)sender {
    
     [self removeFromSuperview];
    
    if (self.weiChat) {
        self.weiChat();
    }
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
 
    [self removeFromSuperview];
}

@end
